package com.yhb.controller.admin;

import com.yhb.controller.vo.ArrayWrapperVo;
import com.yhb.model.Order;
import com.yhb.model.User;
import com.yhb.model.mq.TimeRangeParam;
import com.yhb.service.OrderService;
import me.edzh.spring.bootstrap.annotations.NeedAuth;
import me.edzh.spring.bootstrap.model.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RequestMapping("/admin/order")
@RestController


public class AdminOrderController {

    @Autowired
    private OrderService orderService;

    @PostMapping("/list")
    @NeedAuth(User.A_ADMIN)
    public Response<ArrayWrapperVo<Order>> getOrderList(@RequestBody TimeRangeParam param) {
        return Response.ok(new ArrayWrapperVo<>(orderService.orderInRange(param.getStartTime(), param.getEndTime())));
    }
    @PostMapping("/send")
    @NeedAuth(User.A_ADMIN)
    public Response sendOrder(@RequestBody Order order) {
        orderService.sendOrder(order.getId(), order.getDeliverCorpName(), order.getDeliverTradeNo());
        return Response.ok();
    }
}
